import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';
import 'package:lanzou_dart/lanzou_dart.dart';

class Api {
  // Gitee 仓库 路径
  static String giteeurl = "";
  // static String giteeNameUrl = "https://gitee.com/li0shang/softwareAPI";
  // static String appListApi = "$giteeNameUrl/raw/master/appList.json";

  static Dio dio = Dio(BaseOptions(
    headers: {"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"},
  ));
  static const channel = BasicMessageChannel("applist_channel", StringCodec());

  // static initurl() {
  //   channel.setMessageHandler((message) async {
  //     giteeurl = message!;
  //     debugPrint("我接受到了数据-->$giteeurl");
  //     return "Dart接受到了数据->告诉你一下";
  //   });
  // }

  static Future getAppList() async {
    giteeurl = (await channel.send("Dart->我来请求数据"))!;
    debugPrint(giteeurl);
    Response res = await dio.get(giteeurl);
    return res.data;
  }

  static Future<String> getlanzouzl(String url) async {
    Lanzoujx lzjx = Lanzoujx();
    String zl = await lzjx.getZL(url);
    return zl;
  }
}
